<!--
 * @Author: your name
 * @Date: 2021-07-20 14:21:01
 * @LastEditTime: 2021-10-14 13:37:19
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \usp-osm-frondend\src\views\masterData\attachment\details.vue
-->
<template>
  <div
    class="white-content"
    v-loading="pageLoading"
    element-loading-text="loading"
  >
    <div class="newPageTitle">
      <span class="backIcon" @click="goBack"><i class="el-icon-back"></i></span>
      <h1 style="display: inline-block; margin-left: 10px; font-weight: bold">
        附件主数据详情
      </h1>
    </div>
    <div class="detail-content-section">
      <h2>
        <span>物料号：{{ datas.materialNo }}</span>
        <!-- <span style="float: right"> 状态：{{ getDictionaryNameByCode('SERVICESTATUS', datas.status)  }} </span> -->
      </h2>
      <el-form label-width="160px" label-position="left">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="物料名称：">
              {{ datas.materialName }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="品牌名称：">
              {{ datas.brandName }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="供应商名称：">
              {{ datas.supplier }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="detail-content-section">
      <el-form label-width="120px" label-position="left">
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="单位：">
              {{ datas.unit }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="长度：">
              {{ datas.length }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="宽度：">
              {{ datas.width }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="高度：">
              {{ datas.high }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="重量：">
              {{ datas.weight }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="体积：">
              {{ datas.volume }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="颜色：">
              {{ datas.color }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="成分/材料：">
              {{ datas.materials }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="保质期：">
              {{ datas.expirationDate | timestampToChange('time') }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="服务商名称：">
              {{ datas.providerName }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="服务商编码：">
              {{ datas.providerCode }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="创建人：">
              {{ datas.createUserName }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="创建时间：">
              {{ datas.createTime | timestampToChange('time') }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="更新时间：">
              {{ datas.updateTime | timestampToChange('time') }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否易碎：">
              {{ datas.whetherFragile === '0' ? '否' : '是' }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="是否为危险品：">
              {{ datas.whetherDangerous === '0' ? '否' : '是' }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import { setRouterParams, getRouterParams } from '@/utils/auth'
import { common } from '@/mixins/common'
import { getAttachmentDetail } from '@/api/masterData'
import { mapGetters } from 'vuex'
export default {
  name: 'attachmentDetails',
  data () {
    return {
      datas: {},
      pageLoading: false,
      id: ''
    }
  },
  mixins: [common],
  computed: {
    ...mapGetters(['lookupItems'])
  },
  mounted () {
    let params = {}
    if (this.$route.params.id) {
      setRouterParams(this.$route)
      params = this.$route.params
    } else {
      params = getRouterParams(this.$route)
    }
    this.id = params.id
    this.getDetail(this.id)
  },
  methods: {
    goBack () {
      this.$router.go(-1)
    },
    getDetail (id) {
      this.pageLoading = true
      getAttachmentDetail(id).then((res) => {
        if (res) {
          if (Number(res.code) === 1) {
            this.datas = res.obj
          } else {
            this.$alert('获取附件主数据详情失败')
          }
          this.pageLoading = false
        }
      }).catch(() => {
        this.pageLoading = false
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.footer {
  width: 100%;
  margin: 0;
}
.detail-section {
  h2 {
    margin: 15px 0;
    font-weight: bold;
  }
}
/deep/ .el-form-item {
  margin-bottom: 0;
}
</style>
